<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<!--
        This program is free software; you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation; either version 2 of the License, or
        (at your option) any later version.

        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.

        You should have received a copy of the GNU General Public License
        along with this program; if not, write to the Free Software
        Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
        MA 02110-1301, USA.
-->

<html>
  <head>
    <meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <meta HTTP-EQUIV="Expires" CONTENT="-1">
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <link type="text/css" href="../../css/jquery-ui/current/jquery-ui.css"
    rel="stylesheet" />
    <link type="text/css" href="../../css/iframe.css" rel="stylesheet" />
    <script type="text/javascript" src="../../js/jquery.js"></script>
    <script type="text/javascript" src="../../js/jquery-ui.js"></script>
    <script type="text/javascript" src="../../js/jquery.xslt.js"></script>
    <script type="text/javascript" src="../../js/jquery.form.js"></script>
    <script type="text/javascript" src="../../js/iframe.js"></script>
  </head>
  <body style="font-size:12px;">
    <form action="../../../../bin/kernel.py?func=postmrt" method="post"
	  id="mrtform">
      <table>
	<tr>
	  <td>code:</td>
	  <td>
	    <div id="autoRepairCodeDiv"></div>
	    <input type='hidden' value="0" name="autoRepairCodeInput"
		   id="autoRepairCodeInput">
	  </td>
	  <td>
	    Model:
	    <img onClick="javascript:update('model');"
		 src="../../img/update.png" title="Update model..."/>
	    <img onClick="javascript:parent.showDialog('modelform');"
		 src="../../img/add.png" title="Add model..."/>
	  </td>
	</tr>
	<tr>
	  <td>Repair type:</td>
	  <td colspan=2><input type="text" style="width:400px" name="repairType"
		     id="repairType" /></td>
	</tr>
	<tr>
	  <td>Repair type description Rus:</td>
	  <td colspan=2>
	    <input type="text" style="width:400px" name="repairTypeRus"
		   id="repairTypeRus" />
	  </td>
	</tr>
	<tr>
	  <td>Spare parts consumption:</td>
	  <td align="right">
	    <input type='hidden' value="0" id="GUID" name="guid">
	    <button type="button"
		    onClick="javascript:parent.showDialog('SPConsumption2');">
	      select...
	    </button>
	    <script language="javascript">
	      function updateSPC()
	      {
	      var tempTime = new Date();
	      var timestamp = tempTime.getTime();
	       $("#GUID").attr('value', timestamp);
	      parent.dialogData.SPConsumption.getid2 = timestamp;
	      }
	      updateSPC();
	    </script>
	  </td>
	  <td rowspan=5>
	    <div id="model"></div>
	  </td>
	</tr>
	<tr>
	  <td>Repair type price:</td>
	  <td><input type="text" style="width:200px" name="repairTypePrice"
		     id="repairTypePrice" /></td>
	</tr>
	<tr>
	  <td>Spare parts price:</td>
	  <td><input type="text" style="width:200px" name="repairPartsPrice"
		     id="repairPartsPrice" /></td>
	</tr>
	<tr>
	  <td>
	    Currency:
	    <img onClick="javascript:update('currency');"
		 src="../../img/update.png" title="Update currency..."/>
	    <img onClick="javascript:parent.showDialog('currencyform');"
		 src="../../img/add.png" title="Add currency..."/>
	  </td>
	  <td>
	    <div id="currency"></div>
	  </td>
	</tr>
	<tr>
	  <td>
	    Customer:
	    <img onClick="javascript:update('customerlist');"
		 src="../../img/update.png" title="Update Customer" />
	    <img ocClick="javascript:parent.showDialog('customer');"
		 src="../../img/add.png" title="Add customer" />
	  </td>
	  <td>
	    <div id="customerlist"></div>
	  </td>
	</tr>
	<tr>
	  <td colspan="3" align="right">
	    <button type="submit">Add repair type</button>
	  </td>
	</tr>
      </table>
    </form>
    <script language="javascript">
      function updateMRTAI() {
	  $.ajax({type: "GET",
		  url: "../../../../bin/kernel.py?func=getMRTAI",
		  success: function(msg){
		      $('#autoRepairCodeDiv').text(msg);
		      $('#autoRepairCodeInput').attr('value', msg);
		  }
		 }
		);
      }

      $(function() {
	  parent.update_api.mrtform.model.func = update;
	  parent.update_api.mrtform.currency.func = update;
	  parent.editRT = editRT;
	  update("currency");
	  update("model");
	  update("customerlist");
	  updateMRTAI();

	  $("#mrtform").ajaxForm(function() {
	      alert("Added!!!");
	      updateSPC();
	      updateMRTAI();
	      $('#mrtform').resetForm();
	  });
      });
    </script>
  </body>
</html>
